function out = momentsGMMData(data,autoLagsIdx,inclMoms)
% This function selects moments from the following empirical data moments
%  - E[y]
%  - E[y(i)*y(j)]       for i=1:ny and j=i,ny
%  - E[y(i)_t*y(i)_t-k] for i=1:ny and k=1,2,...autoLoag 
% Max number of moment conditions: ny + ny*(ny+1)/2 + ny*lags

% Number of observations (T) and number of observables (ny)
[T,ny] = size(data);

% The means
maxLag   = max(autoLagsIdx);
autoEyy  = zeros(ny,ny,maxLag);
Ey       = sum(data,1)'/T;
Eyy      = data'*data/T;
for i=1:maxLag
    autoEyy(:,:,i) = data(1+i:T,:)'*data(1:T-i,:)/(T-i);
end

% We collect the moments we need for estimation
[dataMomentsFull,nameMomentsFull] = collectMoments(Ey,Eyy,autoEyy,autoLagsIdx);
% Removing potential moments
dataMoments = dataMomentsFull(inclMoms==1);
nameMoments = nameMomentsFull(inclMoms==1);

%% reporting output
out.dataMoments     = dataMoments;
out.nameMoments     = nameMoments;
out.dataMomentsFull = dataMomentsFull;
out.nameMomentsFull = nameMomentsFull;
end

